package com.hongye.house.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hongye.house.entity.HongyeBannerEntity;
import com.hongye.house.service.HongyeBannerService;
import com.hongye.common.utils.PageUtils;
import com.hongye.common.utils.R;



/**
 * 
 *
 * @author gxx
 * @email hongyezhaofang.com
 * @date 2021-10-14 19:10:20
 */
@RestController
@RequestMapping("house/hongyebanner")
public class HongyeBannerController {
    @Autowired
    private HongyeBannerService hongyeBannerService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = hongyeBannerService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{bannerId}")
    public R info(@PathVariable("bannerId") Integer bannerId){
		HongyeBannerEntity hongyeBanner = hongyeBannerService.getById(bannerId);

        return R.ok().put("hongyeBanner", hongyeBanner);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody HongyeBannerEntity hongyeBanner){
		hongyeBannerService.save(hongyeBanner);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody HongyeBannerEntity hongyeBanner){
		hongyeBannerService.updateById(hongyeBanner);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] bannerIds){
		hongyeBannerService.removeByIds(Arrays.asList(bannerIds));

        return R.ok();
    }

}
